<!-- 进程管控 -->
<template>
<div>
  <el-row>
    <div style="display:flex;flex-direction: column;margin-top:15px;">
      <el-radio style="margin-bottom:15px" v-model="auditForm.Policy" :label="1">不启用网络审计功能模块，所有网络行为不审计不阻断</el-radio>
      <el-radio style="margin-bottom:15px" v-model="auditForm.Policy" :label="2">学习模式(只上送日志，不阻断，常见为实施部署初始阶段)</el-radio>
      <el-radio style="margin-bottom:15px" v-model="auditForm.Policy" :label="3">默认阻断模式(当网络行为匹配不到规则时，默认阻断该网络行为)</el-radio>
      <el-radio style="margin-bottom:15px" v-model="auditForm.Policy" :label="4">默认放行模式(当网络行为匹配不到规则时，默认放行该网络行为)</el-radio>
    </div>
  </el-row>
</div>
</template>

<script>
import { connrequest } from '@/api/firstPage'
export default {
data() {
return {
  auditForm:{
    Policy: 1
  },
}
},
//生命周期 - 创建完成（访问当前this实例）
created() {
  this.getData()
},
//生命周期 - 挂载完成（访问DOM元素）
mounted() {
},
methods: {
  async getData(){
    const data = { 
      Filter: {
        FileName: 'param_proc_white_dir.json'
      }
    }
    const res = await connrequest('GetUICommonParam', data)
    let arr = [];
    res.Data.map(item => {
      arr.push({Name: item})
    })
    this.tableData = arr
  },
  add(){
    this.auditForm = {}
    this.auditdialog = true
  },
  async submit(){
    if(!this.auditForm.Name){
      this.$message.error('目录名称不能为空')
      return false
    }
    let arr = [...this.tableData]
    arr.push({Name: this.auditForm.Name})
    arr = arr.map(item => item.Name)
    const data = {
      Filter: {
        FileName: 'param_proc_white_dir.json'
      },
      Data: arr
    }
    const res = await connrequest('SetUICommonParam', data)
    if(res.Status.StatusCode === 0){
      this.$message({
        type: 'success',
        message: `添加成功!`
      });
      this.getData()
    }
    this.auditdialog = false
  },
  deleteOnclick(row, index){
    this.$confirm(`确定删除?`, '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(async () => {
      let arr = [...this.tableData]
      arr.splice(index, 1)
      arr = arr.map(item => item.Name)
      const data = {
          Filter: {
            FileName: 'param_proc_white_dir.json'
          },
          Data: arr
        }
      const res = await connrequest('SetUICommonParam', data)
      if(res.Status.StatusCode === 0){
        this.$message({
          type: 'success',
          message: `删除成功!`
        });
        this.getData()
      }
    }).catch(() => {
      this.$message({
        type: 'info',
        message: '已取消删除'
      });          
    });
  },
}
}
</script>